#pragma once

#include "CDXMesh.h"
#include "CDXEffect.h"
#include "CDXTexture2D.h"
#ifndef __SWIG__
#include <D3DX10math.h>
#include <vector>
#include <map>
#endif
class CDXMesh;
class CDXEffect;
#ifdef __SWIG__
%include <typemaps.i>
%include "mui_typemap.i"

%apply SWIGTYPE** OUTPUT { ID3D11UnorderedAccessView** ppUnorderAccessView};
%apply SWIGTYPE** OUTPUT { ID3D11ShaderResourceView** ppShaderResourceView};
%apply SWIGTYPE** OUTPUT { ID3D11RenderTargetView** ppRenderTargetView};
%apply SWIGTYPE** OUTPUT { CDXEffect** ppEffect};
%apply SWIGTYPE** OUTPUT { CDXTexture2D** ppTexture};
%apply SWIGTYPE** OUTPUT { ID2D1SolidColorBrush** ppBrush};
%apply SWIGTYPE** OUTPUT { CDXMesh** ppMesh};

#endif
class CDXEffectLibrary : public CDXBase
{
protected: 
	std::map<std::wstring, CDXEffect*> m_pEffectPathMap;
	std::map<std::string, CDXEffect*> m_pEffectNameMap;
public:
	CDXEffectLibrary(CDXDevice* pDevice);
	virtual ~CDXEffectLibrary();
	virtual HRESULT LoadEffectFromFile(const WCHAR* path, const char* name);
	virtual HRESULT GetEffectByPath(const WCHAR* path, CDXEffect** ppEffect);
	virtual HRESULT GetEffectByName(const char* name, CDXEffect** ppEffect);
};


class CDXTextureLibrary : public CDXBase
{
protected:
	std::map<std::wstring, CDXTexture2D*> m_pTexturePathMap; 
public:
	CDXTextureLibrary(CDXDevice* pDevice);
	virtual ~CDXTextureLibrary();
	virtual HRESULT LoadTextureFromFile(WCHAR* path);
	virtual HRESULT GetTextureByPath(WCHAR* path, CDXTexture2D** ppTexture);

};


class CD2DColorBrushLibrary : public CDXBase
{
protected: 

public:
#ifndef __SWIG__
	struct ColorBrushKey
	{
		ID2D1RenderTarget* pD2DRT;
		D2D1_COLOR_F color;
	};
	std::map<ColorBrushKey, ID2D1SolidColorBrush*> m_pColorBrushMap; 
#endif
public:
	CD2DColorBrushLibrary(CDXDevice* pDevice);
	virtual ~CD2DColorBrushLibrary();
	virtual HRESULT CreateSolidColorBrush(ID2D1RenderTarget* pD2DRT, const D2D1_COLOR_F& color);
	virtual HRESULT GetSolidColorBrush(ID2D1RenderTarget* pD2DRT, const D2D1_COLOR_F& color, ID2D1SolidColorBrush** ppBrush);
	
};

class CDXMeshLibrary : public CDXBase
{
protected:
	std::map<std::string, CDXMesh*> m_pMeshNameMap; 
	std::map<std::wstring, CDXMesh*> m_pMeshPathMap; 
public:
	CDXMeshLibrary(CDXDevice* pDevice);
	virtual ~CDXMeshLibrary();
	virtual HRESULT LoadMeshFromFile(const WCHAR* path, const char* name);
	virtual HRESULT SetMesh(CDXMesh* pmesh, const char* name);
	virtual HRESULT GetMeshByPath(const WCHAR* path, CDXMesh** ppMesh);
	virtual HRESULT GetMeshByName(const char* name, CDXMesh** ppMesh);
};

#ifndef __SWIG__
bool operator < (const CD2DColorBrushLibrary::ColorBrushKey& key1, const CD2DColorBrushLibrary::ColorBrushKey& key2);
#endif